<template>
  <div>
    <div class="existing-row" v-if="existingTypeData.length > 0" :style="{ height: isshow ? '':'35px'}" style="overflow: hidden;">
      <div class="btn-row">
        <el-button type="primary" size="medium" @click="isshow=!isshow">{{isshow?'收起':'展开'}}</el-button>
        <el-button type="primary" size="medium" @click="handleDisposition()"
          >一键配置</el-button
        >
      </div>
      <el-tabs v-model="activeName">
        <el-tab-pane
          :label="`${item.name}阈值`"
          :name="item.type"
          :key="item.type"
          v-for="item of existingTypeData"
        >
          <el-form
            :ref="`pojoForm${item.type}`"
            :model="item.threshold"
            :rules="rules"
            :hide-required-asterisk="true"
            class="Plugsetup-row"
          >
            <div class="Plugsetup-list">
              <div class="Plugsetup-title">过压保护(V)</div>
              <el-form-item label="自动断电：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.ov_electricity"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="报警推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.ov_alarm"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="恢复推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.ov_restore"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <div
                class="Plugsetup-box"
                v-if="item.type == '110' || item.type == '1501'"
              >
                <span>蜂鸣器是否启用：</span>
                <el-checkbox v-model="item.threshold.ov_buzzer"></el-checkbox>
              </div>
              <el-form-item
                label="过压阈值："
                prop="ov_alarm_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.ov_alarm_value"></el-input>
              </el-form-item>
              <el-form-item
                label="恢复阈值："
                prop="ov_restore_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.ov_restore_value"></el-input>
              </el-form-item>
            </div>
            <div class="Plugsetup-list">
              <div class="Plugsetup-title">欠压保护(V)</div>
              <el-form-item label="自动断电：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.uv_electricity"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="报警推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.uv_alarm"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="恢复推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.uv_restore"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <div
                class="Plugsetup-box"
                v-if="item.type == '110' || item.type == '1501'"
              >
                <span>蜂鸣器是否启用：</span>
                <el-checkbox v-model="item.threshold.uv_buzzer"></el-checkbox>
              </div>
              <el-form-item
                label="欠压阈值："
                prop="uv_alarm_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.uv_alarm_value"></el-input>
              </el-form-item>
              <el-form-item
                label="恢复阈值："
                prop="uv_restore_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.uv_restore_value"></el-input>
              </el-form-item>
            </div>
            <div class="Plugsetup-list">
              <div class="Plugsetup-title">过载保护(W)</div>
              <el-form-item label="自动断电：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.ol_electricity"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="报警推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.ol_alarm"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="恢复推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.ol_restore"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <div
                class="Plugsetup-box"
                v-if="item.type == '110' || item.type == '1501'"
              >
                <span>蜂鸣器是否启用：</span>
                <el-checkbox v-model="item.threshold.ol_buzzer"></el-checkbox>
              </div>
              <el-form-item
                label="过载阈值："
                prop="ol_alarm_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.ol_alarm_value"></el-input>
              </el-form-item>
              <el-form-item
                label="恢复阈值："
                prop="ol_restore_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.ol_restore_value"></el-input>
              </el-form-item>
            </div>
            <div class="Plugsetup-list">
              <div class="Plugsetup-title">温度保护(℃)</div>
              <el-form-item label="自动断电：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.tem_electricity"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="报警推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.tem_alarm"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <el-form-item label="恢复推送：" class="Plugsetup-box">
                <el-switch
                  class="Plugsetup-switch"
                  style="display: block"
                  :active-value="1"
                  :inactive-value="0"
                  v-model="item.threshold.tem_restore"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                >
                </el-switch>
              </el-form-item>
              <div
                class="Plugsetup-box"
                v-if="item.type == '110' || item.type == '1501'"
              >
                <span>蜂鸣器是否启用：</span>
                <el-checkbox v-model="item.threshold.tem_buzzer"></el-checkbox>
              </div>
              <el-form-item
                label="超温阈值："
                prop="tem_alarm_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.tem_alarm_value"></el-input>
              </el-form-item>
              <el-form-item
                label="恢复阈值："
                prop="tem_restore_value"
                class="Plugsetup-box"
              >
                <el-input v-model="item.threshold.tem_restore_value"></el-input>
              </el-form-item>
            </div>
            <div class="Plugsetup-list">
              <div class="Plugsetup-title">其他设置</div>

              <div class="Plugsetup-box">
                <span>本地开关是否启用：</span>
                <el-checkbox
                  v-model="item.threshold.switch_enable"
                ></el-checkbox>
              </div>
            </div>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-table :data="tableData" border style="width: 100%" :height="isshow?'6.7rem':'9.2rem'">
      <el-table-column type="index" label="序号" width="60" align="center">
      </el-table-column>
      <el-table-column prop="channelName" label="探头名称" align="center">
      </el-table-column>
      <el-table-column
        prop="channelName"
        align="center"
        label="过压（V）"
        width="200"
      >
        <template slot-scope="scope">
          <div class="Threshold-row">
            <span
              >自动断电：{{ ProcessingData(scope.row.eleOvElectricity) }}</span
            >
            <!-- <span>报警推送：{{ ProcessingData(scope.row.eleOvAlarm) }}</span> -->
            <!-- <span>恢复推送：{{ ProcessingData(scope.row.eleOvRestore) }}</span> -->
            <!-- <span v-if="scope.row.probeKindCode != 701"
            >蜂鸣器：{{ ProcessingData(scope.row.eleOvBuzzer) }}</span
          > -->
            <span
              >过压阈值：{{ ProcessingData(scope.row.eleOvAlarmValue) }}</span
            >
            <!-- <span
            >恢复阈值：{{ ProcessingData(scope.row.eleOvRestoreValue) }}</span
          > -->
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="hostGuid"
        align="center"
        label="欠压（V）"
        width="200"
      >
        <template slot-scope="scope">
          <div class="Threshold-row">
            <span
              >自动断电：{{ ProcessingData(scope.row.eleUvElectricity) }}</span
            >
            <!-- <span>报警推送：{{ ProcessingData(scope.row.eleUvAlarm) }}</span>
          <span>恢复推送：{{ ProcessingData(scope.row.eleUvRestore) }}</span> -->
            <!-- <span v-if="scope.row.probeKindCode != 701"
            >蜂鸣器：{{ ProcessingData(scope.row.eleUvBuzzer) }}</span
          > -->
            <span
              >欠压阈值：{{ ProcessingData(scope.row.eleUvAlarmValue) }}</span
            >
            <!-- <span
            >恢复阈值：{{ ProcessingData(scope.row.eleUvRestoreValue) }}</span
          > -->
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="address"
        align="center"
        label="过载（W）"
        width="200"
      >
        <template slot-scope="scope">
          <div class="Threshold-row">
            <span
              >自动断电：{{ ProcessingData(scope.row.eleOlElectricity) }}</span
            >
            <!-- <span>报警推送：{{ ProcessingData(scope.row.eleOlAlarm) }}</span>
          <span>恢复推送：{{ ProcessingData(scope.row.eleOlRestore) }}</span>
          <span v-if="scope.row.probeKindCode != 701"
            >蜂鸣器：{{ ProcessingData(scope.row.eleOlBuzzer) }}</span
          > -->
            <span
              >过载阈值：{{ ProcessingData(scope.row.eleOlAlarmValue) }}</span
            >
            <!-- <span
            >恢复阈值：{{ ProcessingData(scope.row.eleOlRestoreValue) }}</span
          > -->
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="locationDesc"
        align="center"
        label="温度（℃）"
        width="200"
      >
        <template slot-scope="scope">
          <div class="Threshold-row">
            <span
              >自动断电：{{ ProcessingData(scope.row.eleTemElectricity) }}</span
            >
            <!-- <span>报警推送：{{ ProcessingData(scope.row.eleTemAlarm) }}</span>
          <span>恢复推送：{{ ProcessingData(scope.row.eleTemRestore) }}</span>
          <span v-if="scope.row.probeKindCode != 701"
            >蜂鸣器：{{ ProcessingData(scope.row.eleTemBuzzer) }}</span
          > -->
            <span
              >超温阈值：{{ ProcessingData(scope.row.eleTemAlarmValue) }}</span
            >
            <!-- <span
            >恢复阈值：{{ ProcessingData(scope.row.eleTemRestoreValue) }}</span
          > -->
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="creationTime" label="低功率" v-if="!include701">
        <template slot-scope="scope">
          <div class="Threshold-row">
          <span>自动断电：{{ ProcessingData(scope.row.eleLpElectricity) }}</span
          >
          <span>报警推送：{{ ProcessingData(scope.row.eleLpAlarm) }}</span
          >
          <span>恢复推送：{{ ProcessingData(scope.row.eleLpRestore) }}</span
          >
          <span>蜂鸣器：{{ ProcessingData(scope.row.eleLpBuzzer) }}</span
          >
          <span>运行时间：{{ ProcessingData(scope.row.eleLpRunTime) }}</span
          >
          </div>
        </template>
      </el-table-column> -->
      <el-table-column
        prop="creationTime"
        align="center"
        label="其他"
        width="200"
      >
        <template slot-scope="scope">
          <div class="Threshold-row">
            <span
              >本地开关：{{ ProcessingData(scope.row.eleSwitchEnable) }}</span
            >

            <span
              >超时关闭：{{
                ProcessingData(scope.row.eleTimeoutShutdown)
              }}</span
            >

            <span v-if="scope.row.eleTimeoutShutdown > 0"
              >最长时间：{{ ProcessingData(scope.row.eleDuration) }}</span
            >
          </div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="130">
        <template slot-scope="scope">
          <el-button
            v-if="
              scope.row.probeKindCode != 701 && scope.row.probeKindCode != 1501
            "
            type="primary"
            size="small"
            @click="handleThreshold(scope.row)"
            >设定阈值</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="disposition-row">
      <el-dialog
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        :visible.sync="dispositionVisible"
        width="850px"
      >
        <div
          style="
            color: #fff;
            text-align: center;
            margin-bottom: 0.2rem;
            font-size: 0.16rem;
          "
        >
          配置中,请勿关闭浏览器
        </div>
        <el-progress
          :text-inside="true"
          :stroke-width="26"
          :percentage="
            parseFloat((((schedule ) / tableData.length) * 100).toFixed(0))
          "
        ></el-progress>
        <div
          style="
            color: #fff;
            text-align: center;
            margin-top: 0.1rem;
            font-size: 0.16rem;
          "
        >
          当前进度：{{ schedule  }}/{{ tableData.length }}
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import ajax from "@/utils/ajax";
const KindCode = [202, 110, 701, 1501, 1801];
let dispositionInterval = null;
// 901
export default {
  data() {
    let validateAlarmValue =
      (minValue, maxValue) => (rule, value, callback) => {
        if (value === "") {
          callback(new Error("不能为空"));
        } else if (value < minValue) {
          callback(new Error(`建议不能小于${minValue}`));
        } else if (value > maxValue) {
          callback(new Error(`建议不能大于${maxValue}`));
        } else {
          callback();
        }
      };
    let durationrule = validateAlarmValue(0, 255);
    let lp_run_timerule = validateAlarmValue(0, 255);
    //过压阈值
    let ov_alarm_value = validateAlarmValue(242, 266);
    //过压恢复阈值
    let ov_restore_value = validateAlarmValue(242, 255);
    //欠压阈值
    let uv_alarm_value = validateAlarmValue(176, 198);
    //欠压恢复阈值
    let uv_restore_value = validateAlarmValue(187, 198);

    //超温阈值
    let tem_alarm_value = validateAlarmValue(60, 80);
    //超温恢复阈值
    let tem_restore_value = validateAlarmValue(50, 75);
    //过载阈值
    let ol_alarm_value = validateAlarmValue(2000, 9240);
    //过载恢复阈值
    let ol_restore_value = validateAlarmValue(50, 1800);

    return {
      tableData: [],
      include701: false,
      existingType: [],
      activeName: "110",
      defaultThreshold: [
        {
          name: "导轨",
          type: "110",
          threshold: {
            ov_electricity: 0,
            ov_alarm: 1,
            ov_restore: 1,
            ov_alarm_value: 265,
            ov_restore_value: 255,
            ov_buzzer: true, //过压蜂鸣器
            uv_electricity: 0,
            uv_alarm: 1,
            uv_restore: 1,
            uv_alarm_value: 180,
            uv_restore_value: 198,
            uv_buzzer: true, //欠压蜂鸣器
            ol_electricity: 0,
            ol_alarm: 1,
            ol_restore: 1,
            ol_alarm_value: "",
            ol_restore_value: "",
            ol_buzzer: true, //过载蜂鸣器
            tem_electricity: 0,
            tem_alarm: 1,
            tem_restore: 1,
            tem_alarm_value: 65,
            tem_restore_value: 55,
            tem_buzzer: true, //超温蜂鸣器
            switch_enable: true,
            duration: 0,
            lp_buzzer: false,
            lp_alarm: 0,
            lp_electricity: 0,
            lp_restore: 0,
            lp_run_time: 0,
            switchdurationEnable: false,
          },
        },
        {
          name: "计量插座",
          type: "202",
          threshold: {
            ov_electricity: 0,
            ov_alarm: 1,
            ov_restore: 1,
            ov_alarm_value: 265,
            ov_restore_value: 255,
            ov_buzzer: true, //过压蜂鸣器
            uv_electricity: 0,
            uv_alarm: 1,
            uv_restore: 1,
            uv_alarm_value: 180,
            uv_restore_value: 198,
            uv_buzzer: true, //欠压蜂鸣器
            ol_electricity: 0,
            ol_alarm: 1,
            ol_restore: 1,
            ol_alarm_value: "",
            ol_restore_value: "",
            ol_buzzer: true, //过载蜂鸣器
            tem_electricity: 0,
            tem_alarm: 1,
            tem_restore: 1,
            tem_alarm_value: 65,
            tem_restore_value: 55,
            tem_buzzer: true, //超温蜂鸣器
            switch_enable: true,
            duration: 0,
            lp_buzzer: false,
            lp_alarm: 0,
            lp_electricity: 0,
            lp_restore: 0,
            lp_run_time: 0,
            switchdurationEnable: false,
          },
        },
      ],
      rules: {
        ov_alarm_value: [{ validator: ov_alarm_value, trigger: "blur" }],
        ov_restore_value: [{ validator: ov_restore_value, trigger: "blur" }],
        uv_alarm_value: [{ validator: uv_alarm_value, trigger: "blur" }],
        uv_restore_value: [{ validator: uv_restore_value, trigger: "blur" }],
        ol_alarm_value: [{ validator: ol_alarm_value, trigger: "blur" }],
        ol_restore_value: [{ validator: ol_restore_value, trigger: "blur" }],
        tem_alarm_value: [{ validator: tem_alarm_value, trigger: "blur" }],
        tem_restore_value: [{ validator: tem_restore_value, trigger: "blur" }],
        duration: [{ validator: durationrule, trigger: "blur" }],
        lp_run_time: [{ validator: lp_run_timerule, trigger: "blur" }],
      },
      //
      dispositionVisible: false,
      schedule: 0,
      isshow:true
    };
  },
  props: {
    areaid: {
      type: Number,
    },
  },
  created() {
    this.getProdData();
  },
  computed: {
    ProcessingData() {
      return function (data) {
        if (data == null || data == -1) {
          return "未配置";
        } else {
          if (data > 1) {
            return data;
          } else {
            return data == 1 ? "开启" : "关闭";
          }
        }
      };
    },

    AreaId() {
      return this.areaid;
    },
    existingTypeData() {
      let data = this.defaultThreshold.filter((data) =>
        this.existingType.includes(data.type)
      );
      return data;
    },
  },
  methods: {
    getProdData() {
      let self = this;
      ajax.get({
        url: this.$API.getProbeChannelByAreaId + this.areaid,
        success: (response) => {
          if (response.data != null && response.data.length > 0) {
            let data = response.data
              .filter((data) => KindCode.includes(parseInt(data.probeKindCode)))
              .map(({ ...data }) => {
                //let threshold ={}
                // if(data.probeKindCode==901){
                //   let HighCurrent = eval('(' + data.nbHighCurrent + ')')
                //   let LowCurrent = eval('(' + data.nbLowCurrent + ')')
                //   let LowPower = eval('(' + data.nbLowPower + ')')
                //   let LowPowerFactor = eval('(' + data.nbLowPowerFactor + ')')
                //   let OverLoad = eval('(' + data.nbOverLoad + ')')
                //   let OverVoltage = eval('(' + data.nbOverVoltage + ')')
                //   let UnderVoltage = eval('(' + data.nbUnderVoltage + ')')
                //    threshold ={
                //     ...data,
                //     eleOvElectricity:HighCurrent.AutoOff,
                //     eleOvAlarm:HighCurrent.AlarmPush,
                //     eleOvRestore:HighCurrent.ResumePush,
                //     eleOvAlarmValue:HighCurrent.AlarmValue,
                //     eleOvRestoreValue:HighCurrent.ResumeValue,

                //     eleUvElectricity:UnderVoltage.AutoOff,
                //     eleUvAlarm:UnderVoltage.AlarmPush,
                //     eleUvRestore:UnderVoltage.ResumePush,
                //     eleUvAlarmValue:UnderVoltage.AlarmValue,
                //     eleUvRestoreValue:UnderVoltage.ResumeValue,

                //     eleOlElectricity:OverLoad.AutoOff,
                //     eleOlAlarm:OverLoad.AlarmPush,
                //     eleOlRestore:OverLoad.ResumePush,
                //     eleOlAlarmValue:OverLoad.AlarmValue,
                //     eleOlRestoreValue:OverLoad.ResumeValue,

                //     eleOlElectricity:LowPower.AutoOff,
                //     eleOlAlarm:LowPower.AlarmPush,
                //     eleOlRestore:LowPower.ResumePush,
                //     eleOlAlarmValue:LowPower.AlarmValue,
                //     eleOlRestoreValue:LowPower.ResumeValue,
                //   }
                // }else{
                //   threshold ={
                //     ...data
                //   }
                // }
                return {
                  ...data,
                };
              });
            // if(data.length>0){
            //   this.include701 =data.filter((data) =>data.probeKindCode == 701).length > 0?true:false
            // }
            self.tableData = data;
            const uniqueSet = new Set(data.map((item) => item.probeKindCode));
            this.existingType = Array.from(uniqueSet);
          } else {
            self.tableData = [];
            self.existingType = [];
          }
        },
      });
    },
    handleThreshold(row) {
      const hasEmptyValue = this.existingTypeData.some((item) => {
        const { threshold } = item;
        return Object.values(threshold).some((value) => value === "");
      });
      if (hasEmptyValue) {
        this.$message({
          message: "请核实阈值是否有未填项",
          type: "error",
        });
      } else {
        let threshold = {
          ...this.existingTypeData.find(
            (data) => data.type === row.probeKindCode
          ).threshold,
        };

        threshold = {
          ...threshold,
          switch_enable: threshold.switch_enable ? 1 : 0,
          lp_buzzer: threshold.lp_buzzer ? 1 : 0,
          ol_buzzer: threshold.ol_buzzer ? 1 : 0,
          ov_buzzer: threshold.ov_buzzer ? 1 : 0,
          uv_buzzer: threshold.uv_buzzer ? 1 : 0,
          tem_buzzer: threshold.tem_buzzer ? 1 : 0,
          duration: threshold.switchdurationEnable ? threshold.duration : 0,
          id: row.probeId,
        };
        ajax.post({
          url: this.$API.setSocketProgram + threshold.id,
          data: threshold,
          success: (response) => {
            //console.log(response)
            if (response.success) {
              this.getProdData()
              this.$message({
                message: response.message,
                type: "success",
              });
            }
          },
        });
      }
    },
    handleDisposition() {
      const hasEmptyValue = this.existingTypeData.some((item) => {
        const { threshold } = item;
        return Object.values(threshold).some((value) => value === "");
      });
      if (hasEmptyValue) {
        this.$message({
          message: "请核实阈值是否有未填项",
          type: "error",
        });
      } else {
        this.$confirm("将一键配置所有设备阈值, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.dispositionVisible = true;
            dispositionInterval = setInterval(() => {
             
              if (this.schedule > this.tableData.length - 1) {
                this.dispositionVisible = false;
                clearInterval(dispositionInterval);
                dispositionInterval = null;
                this.schedule = 0;
                this.getProdData()
                this.$message({
                  message: "配置完成",
                  type: "success",
                });
              } else {
                let data = this.tableData[this.schedule];
                if (data.probeKindCode == 202 || data.probeKindCode == 110) {
                  let threshold = {
                    ...this.existingTypeData.find(
                      (item) => item.type === data.probeKindCode
                    ).threshold,
                  };

                  threshold = {
                    ...threshold,
                    switch_enable: threshold.switch_enable ? 1 : 0,
                    lp_buzzer: threshold.lp_buzzer ? 1 : 0,
                    ol_buzzer: threshold.ol_buzzer ? 1 : 0,
                    ov_buzzer: threshold.ov_buzzer ? 1 : 0,
                    uv_buzzer: threshold.uv_buzzer ? 1 : 0,
                    tem_buzzer: threshold.tem_buzzer ? 1 : 0,
                    duration: threshold.switchdurationEnable
                      ? threshold.duration
                      : 0,
                    id: data.probeId,
                  };
                  // console.log(threshold);
                  ajax.post({
                    url: this.$API.setSocketProgram + threshold.id,
                    data: threshold,
                    showLoading: false,
                    success: (response) => {
                      //console.log(response)
                      if (response.success) {
                       return
                      }
                    },
                  });
                } else {
                  return;
                }
                this.schedule++;
              }
            }, 5000);
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消",
            });
          });
      }
    },
  },
  filters: {},
  watch: {
    AreaId() {
      this.getProdData();
    },
  },
};
</script>
<style scoped>
.updata-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
::v-deep.el-table--striped .el-table__body tr.el-table__data--striped td {
  background: inherit;
}
.Threshold-row {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
}
/* .Threshold-row span:nth-of-type(2n) {
    margin-left: 0.1rem;
} */
.Threshold-row span {
  font-size: 0.13rem;
}

.Plugsetup-row {
  display: flex;
  justify-content: space-between;
}
::v-deep.Plugsetup-row .el-form-item__error {
  left: -45px;
  right: 0;
  text-align: right;
}
::v-deep.Plugsetup-row .is-error {
  margin-bottom: 0.1rem !important;
}
.Plugsetup-title {
  color: #fff;
  font-size: 14px;
  text-align: center;
  position: relative;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.Plugsetup-title::before {
  content: "";
  height: 3px;
  width: 20px;
  bottom: 0;
  display: block;
  position: absolute;
  background: #01ceef;
  left: calc(50% - 10px);
}

.Plugsetup-box {
  display: flex;
  align-items: center;
  color: #fff;
  padding-bottom: 10px;
  margin-bottom: 0;
  justify-content: space-between;
}

.Plugsetup-list {
  position: relative;
}

.Plugsetup-list::before {
  content: "";
  height: 170px;
  width: 1px;
  top: 17px;
  display: block;
  position: absolute;
  background-image: linear-gradient(
      0deg,
      rgb(22 33 77) 0%,
      rgb(81 151 255) 50%,
      rgb(22 33 77) 100%
    ),
    linear-gradient(#16214d, #16214d);
  right: -43%;
}
.Plugsetup-list:last-child::before {
  display: none;
}
::v-deep .Plugsetup-box .el-form-item__label {
  line-height: 1;
  padding-left: 0.05rem;
  color: #fff;
}

::v-deep .Plugsetup-box.el-form-item:after,
::v-deep .Plugsetup-box.el-form-item:before {
  display: none;
}

::v-deep .Plugsetup-box .el-form-item__content {
  line-height: 1;
}

::v-deep .Plugsetup-box .el-input input.el-input__inner {
  height: 30px;
  padding: 0 0.05rem;
  font-size: 0.12rem;
}

.Plugsetup-box .el-input {
  width: 60px;
}
.Plugsetup-list span {
  padding-left: 0.05rem;
}

.existing-row {
  background: #202c5f;
  position: relative;
  padding: 0.1rem;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  border: 1px solid #cfcfcf;
}

.existing-row .Plugsetup-row {
  justify-content: space-around;
}
::v-deep.existing-row .el-tabs__nav-scroll {
  padding-left: 0.2rem;
}
::v-deep.existing-row .el-tabs__item {
  color: #fff;
}
::v-deep.existing-row .el-tabs__item.is-active {
  color: #409eff;
}
::v-deep.disposition-row .el-dialog__header {
  display: none;
}
.btn-row {
    position: absolute;
    right: 0.1rem;
        z-index: 1;
}
</style>